package com.liulihui.web.vo;

/**
 * @ClassName: Result
 * @Description:
 * @Author liulihui 统一返回的数据格式类型
 * @Date: 2021/8/4 12:27
 * @URL：
 * @Version 1.0
 */
public class Result {

    private int code;
    private String message;
    private Object data;  //不知返回的数据是什么类型,所以定义成Object

    public Result(ResultInfoEnum code_server_unknown_error) {

    }


    public static Result success(){
        return new Result(ResultInfoEnum.CODE_SUCCESS,null);
    }

    public static Result success(Object data){
        return new Result(ResultInfoEnum.CODE_SUCCESS,data );
    }
    public static Result clientError(){
        return new Result(ResultInfoEnum.CODE_CLIENT_LEN_ERROR,null);
    }
    public static Result clientError(Object data){
        return new Result(ResultInfoEnum.CODE_CLIENT_IS_NOT_NUMBER,data);
    }
 public static Result serverError(){
        return new Result(ResultInfoEnum.code_server_unknown_error);
 }

  public  Result(ResultInfoEnum resultInfoEnum,Object data){
        this.code=resultInfoEnum.getCode();
        this.message=resultInfoEnum.getMsg();
        this.data=data;
  }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}